var e = require, t = module, n = exports;

Object.defineProperty(n, "__esModule", {
    value: !0
});

var o = e("Global"), i = e("PlayerMain"), a = e("PlayerModel"), r = e("ArmView"), s = e("AudioManager"), c = e("LoadManager"), l = function() {
    function e() {}
    return e.getInstance = function() {
        return this._manager || (this._manager = new e()), this._manager;
    }, e.prototype.loadSkin = function(n) {
        return new Promise(function(o, t) {
            c.default.getInstance().loadRes({
                url: "skin/213/skeleton",
                type: sp.SkeletonData
            }).then(function(e) {
                n.skeleton && e instanceof sp.SkeletonData && (n.skeleton.skeletonData = e, n.changeAnimation({
                    animation: "animation2",
                    loop: !0
                })), o();
            }).catch(function(e) {
                console.error(e), t();
            });
        });
    }, e.prototype.doHurt = function(e, o, t) {
        e.canHurt() && (e.checkHurt(o, t, e.metamorphicModel), e.metamorphicModel.isDead() ? this.die(e) : (e.canMove() && t && (e.offect = t.mul(10 * o.pow)), 
        e.isHurt || (e.isHurt = !0, cc.tween(e.skeleton.node).repeat(2, cc.tween().call(function() {
            e.skeleton.node.color = cc.Color.RED;
        }).delay(.08).call(function() {
            e.skeleton.node.color = cc.Color.WHITE;
        }).delay(.08)).call(function() {
            e.isHurt = !1;
        }).start()), o.type == a.ArmType.闪电枪 ? e.doEle(function() {
            e.model.hasBuffer(a.BufferType.变身) || e.loadSkin(e.model.personIdx).then(function() {
                e.skeleton && e.skeleton.node.setPosition(cc.v2(0, -20));
            });
        }) : o.type == a.ArmType.冰冻枪 ? e.doIce() : o.type == a.ArmType.切割 && e.doCut()));
    }, e.prototype.die = function(l) {
        l.model.addBuffer(a.BufferType.变身), l.model.addBuffer(a.BufferType.无敌), l.pauseMove(!0), 
        l.sprite && (l.sprite.node.opacity = 0), l.skeleton && l.skeleton.node.setPosition(cc.v2(0, -20)), 
        c.default.getInstance().loadRes({
            url: "skeleton/皮肤塞罗凹凸曼死亡/skeleton",
            type: sp.SkeletonData
        }).then(function(e) {
            l.skeleton.skeletonData = e, l.skeleton.setAnimation(0, "animation", !1), l.skeleton.setCompleteListener(function() {
                l.skeleton.setCompleteListener(null);
                var t = o.G.getCirclePoints(1, cc.v2(0, 0), 8), n = 0;
                l.schedule(function() {
                    s.default.getInstance().playAudio("飞镖");
                    var e = l.gameView.getArm().getComponent(r.default);
                    e && (e.node.setParent(l.gameView.bulletLayout), e.node.setPosition(l.node.getPosition().add(t[n % t.length].mul(20))), 
                    e.init(l, l.metamorphicModel, t[n % t.length].mul(2), l.node.getPosition().add(t[n % t.length].mul(20)))), 
                    n++;
                }, .1, 7), l.modelType = i.ModelType.DEFAULT, l.loadSkin(l.model.personIdx).then(function() {
                    l.model.removeBuffer(a.BufferType.变身), l.model.removeBuffer(a.BufferType.无敌), l.resumeMove(!0), 
                    l.sprite && l.canShowGun() && (l.sprite.node.opacity = 255), l.hpView.init(l.model.MAX_HP), 
                    l.hpView.refresh(l.model.HP);
                });
            });
        });
    }, e.prototype.change = function(t) {
        t.metamorphicModel.flag = !0, t.model.addBuffer(a.BufferType.变身), t.model.addBuffer(a.BufferType.无敌), 
        t.pauseMove(!0), t.sprite && (t.sprite.node.opacity = 0), c.default.getInstance().loadRes({
            url: "skeleton/皮肤塞罗凹凸曼/skeleton",
            type: sp.SkeletonData
        }).then(function(e) {
            t.skeleton && (t.skeleton.node.setPosition(cc.v2(0, -20)), t.skeleton.skeletonData = e, 
            t.skeleton.setAnimation(0, "animation", !1), t.skeleton.setCompleteListener(function() {
                t.skeleton.setCompleteListener(null), t.modelType = i.ModelType.METAMORPHIC, t.loadSkin(t.model.personIdx).then(function() {
                    s.default.getInstance().playAudio("彩蛋皮肤塞罗凹凸曼"), t.model.removeBuffer(a.BufferType.变身), 
                    t.model.removeBuffer(a.BufferType.无敌), t.canMove() && t.resumeMove(!0), t.sprite && t.canShowGun() && (t.sprite.node.opacity = 255), 
                    t.metamorphicModel.group = t.model.group, t.metamorphicModel.initModel(t.model), 
                    t.hpView.init(t.metamorphicModel.MAX_HP);
                    var o = t;
                    t.schedule(function() {
                        var e;
                        t.modelType == i.ModelType.METAMORPHIC ? ((e = new a.default()).ATK = Math.ceil(t.metamorphicModel.MAX_HP / 20), 
                        o.doHurt(e), o.metamorphicModel.isDead() && o.unschedule(this)) : o.unschedule(this);
                    }, 1);
                });
            }));
        });
    }, e._manager = null, e;
}();

n.default = l;